module.exports = function(grunt) {

  var sourcePath = {
    css: 'css/',
    js: 'js/'
  };

  var cssTargetPath = {
    raw: 'css/raw/',
    min: 'css/min/'
  };

  var jsTargetPath = {
    raw: 'js/raw/',
    min: 'js/min/'
  };

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '',
    // Task configuration.

    less: {
      general: {
        options: {
          paths: sourcePath.css
        },
        src: [
              sourcePath.css + 'vendor/' + '*.less',
              sourcePath.css + '*.less'
        ],
        dest: sourcePath.css + '_less-temp.css'
      }
    },
    concat: {
      css: {
    	    src:[
                 sourcePath.css + 'vendor/' + '*.css',
                 sourcePath.css + '_less-temp.css',
                 sourcePath.css + '*.css'
            ],
            dest: cssTargetPath.raw + 'default.raw.css'
      },
      // Libraries from (3rd-party) vendors
      jsHead: {
        src: [
              sourcePath.js + 'vendor/' + 'modernizr-2.6.2.min.js'
        ],
        dest: jsTargetPath.raw + 'lib-head.raw.js',
        nonull: true
      },
      jsBodyEnd: {
        src:[
             sourcePath.js + 'vendor/' + 'jquery-1.10.2.min.js',
             sourcePath.js + 'vendor/' + 'bootstrap.min.js',
             sourcePath.js + 'vendor/' + 'carousel.js',
             sourcePath.js + 'plugins.js',
             sourcePath.js + 'vendor/' + 'google-analytics.js'
        ],
        dest: jsTargetPath.raw + 'lib-body.raw.js'
      }
    },

    cssmin: {
      general: {
        src: cssTargetPath.raw + 'default.raw.css',
        dest: cssTargetPath.min + 'default.min.css'
      }
    },

    uglify: {
      jsHead: {
        src: jsTargetPath.raw + 'lib-head.raw.js',
        dest: jsTargetPath.min + 'lib-head.min.js'
      },
      jsBodyEnd: {
        src: jsTargetPath.raw + 'lib-body.raw.js',
        dest: jsTargetPath.min + 'lib-body.min.js'
      }
    },

    clean: {
        build: [
                sourcePath.css + '_*.css',
                sourcePath.raw + '_*.css',
                sourcePath.js + '_*.js'
        ]
    }
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');

  // Default task.
  grunt.registerTask('default', [
    'less',
    'concat',
    'cssmin',
    'uglify',
    'clean'
  ]);

  // Tasks for Prototype
  grunt.registerTask('prototype', [
    'less',
	'concat',
	'cssmin',
	'uglify',
	'clean'
  ]);
};
